package com.yuncheng.spcyApi.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import org.apache.commons.collections.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuncheng.spcyApi.constant.common.BusinessConstant;
import com.yuncheng.spcyApi.constant.jcy.JcyLxjhConstant;
import com.yuncheng.spcyApi.constant.common.LogConstant;
import com.yuncheng.spcyApi.constant.common.SpcyConstant;
import com.yuncheng.spcyApi.entity.*;
import com.yuncheng.exception.BusinessException;
import com.yuncheng.spcyApi.mapper.SpcyPxJbxxMapper;
import com.yuncheng.spcyApi.service.*;
import com.yuncheng.spcyApi.utils.*;
import com.yuncheng.spcyApi.vo.jcy.JcyLxUserVo;
import com.yuncheng.spcyApi.vo.common.OrderItemVo;
import com.yuncheng.spcyApi.vo.common.PageVo;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.yuncheng.common.base.service.impl.BaseServiceImpl;
import utils.DateConversionUtils;
import utils.LogUtils;
import utils.ObjectToMapUtils;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

/**
 * @Description: 审评查验-培训基本信息
 * @Author: yuncheng
 * @Date: 2023-04-14
 * @Version: V1.0
 */
@Service
public class SpcyPxJbxxServiceImpl extends BaseServiceImpl<SpcyPxJbxxMapper, SpcyPxJbxx> implements ISpcyPxJbxxService {

    @Resource
    @Lazy
    private ISpcyPxDjjbxxService spcyPxDjjbxxService;

    @Resource
    private ISpcyPxCjryService spcyPxCjryService;

    @Resource
    @Lazy
    private ISysUserPxjlService sysUserPxjlService;

    @Resource
    @Lazy
    private ISpcyJcyLxqdcsService spcyJcyLxqdcsService;

    @Resource
    private SpcyPxJbxxMapper spcyPxJbxxMapper;

    @Resource
    @Lazy
    private ISpcyLogService spcyLogService;

    @Override
    public Page<SpcyPxJbxx> pageList(SpcyPxJbxx query, String gjz, PageVo pageVo, OrderItemVo orderItemVo) {
        Page<SpcyPxJbxx> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());

        LambdaQueryWrapper<SpcyPxJbxx> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(query.getFfwbh()), SpcyPxJbxx::getFfwbh, query.getFfwbh());
        queryWrapper.like(StringUtils.isNotBlank(query.getFpxbh()), SpcyPxJbxx::getFpxbh, query.getFpxbh());
        queryWrapper.like(StringUtils.isNotBlank(query.getFjhcjlb()), SpcyPxJbxx::getFjhcjlb, query.getFjhcjlb());
        queryWrapper.like(StringUtils.isNotBlank(query.getFjhmc()), SpcyPxJbxx::getFjhmc, query.getFjhmc());
        queryWrapper.like(StringUtils.isNotBlank(query.getFjhzt()), SpcyPxJbxx::getFjhzt, query.getFjhzt());
        queryWrapper.like(StringUtils.isNotBlank(query.getFpxlx()), SpcyPxJbxx::getFpxlx, query.getFpxlx());
        queryWrapper.like(StringUtils.isNotBlank(query.getFjhnd()), SpcyPxJbxx::getFjhnd, query.getFjhnd());

        if (StringUtils.isNotBlank(gjz)){
            queryWrapper
                    .and(f->f.like(SpcyPxJbxx::getFjhmc, gjz)
                            .or()
                            .like(SpcyPxJbxx::getFfwbh, gjz)
                            .or()
                            .like(SpcyPxJbxx::getFjhcjlb, gjz)
                            .or()
                            .like(SpcyPxJbxx::getFjhzt, gjz)
                    );
        }

        if (StringUtils.isBlank(orderItemVo.getOrderItem())){
            queryWrapper.orderByDesc(SpcyPxJbxx::getFjhcjsj);
        }else {
            OrderItemUtils.setOrderItem(queryWrapper, orderItemVo);
        }
        return page(page, queryWrapper);
    }

    @Override
    public SpcyPxJbxx addLxjh(SpcyPxJbxx bean) {
        bean.setId(GetUuIdUtils.ReplaceUuId());
        if (StringUtils.isBlank(bean.getFjhzt())){
            bean.setFjhzt(JcyLxjhConstant.getFirstJhzt());
        }
        if(StringUtils.isBlank(bean.getFpxbmzt())) {
            bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }
        if(StringUtils.isBlank(bean.getFpxqdzt())) {
            bean.setFpxqdzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }
        if(StringUtils.isBlank(bean.getFpxkszt())) {
            bean.setFpxkszt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }
        if (StringUtils.isBlank(bean.getFjhnd())){
            bean.setFjhnd(DateConversionUtils.DateToYear(new Date()));
        }
        if (StringUtils.isNotBlank(bean.getFjhcjsj())){
            bean.setFjhnd(bean.getFjhcjsj().substring(0, 4));
        }

        if (StringUtils.isNotBlank(bean.getFjhcjsj())){
            String nowDate = DateConversionUtils.DateToStringYYYYMMDD(new Date());
            if (bean.getFjhcjsj().compareTo(nowDate) < 0){
                bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_QY);
            }else if (bean.getFjhcjsj().compareTo(nowDate) == 0){
                bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_QY);
            }else {
                bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            }
        }else {
            bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }

        if (StringUtils.isNotBlank(bean.getFjhjzsj())){
            String nowDate = DateConversionUtils.DateToStringYYYYMMDD(new Date());
            if (bean.getFjhjzsj().compareTo(nowDate) < 0){
                bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            }else if (bean.getFjhjzsj().compareTo(nowDate) > 0){
                bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_QY);
            }
        }

        bean.setFpxhgx(60);
        bean.setFpxrs(0);
        bean.setFzzdw(BusinessConstant.Dw_NAME);
        bean.setCreateTime(new Date());
        bean.setUpdateTime(new Date());
        bean.setCreateBy(GetCurrentUserUtils.getCurrentUserAccount());
        bean.setUpdateBy(GetCurrentUserUtils.getCurrentUserAccount());
        save(bean);

        String operContent = "新增信息：";
        operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(bean));
        spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,operContent,bean.getId(), "添加遴选计划", SpcyConstant.LOGS_SYS_TYPE_XZ);

        return bean;
    }

    @Override
    public SpcyPxJbxx addJxjy(SpcyPxJbxx bean) {
        bean.setId(GetUuIdUtils.ReplaceUuId());
        if (StringUtils.isBlank(bean.getFjhzt())){
            bean.setFjhzt(JcyLxjhConstant.getFirstJhzt());
        }
        if(StringUtils.isBlank(bean.getFpxbmzt())) {
            bean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }
        if(StringUtils.isBlank(bean.getFpxqdzt())) {
            bean.setFpxqdzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }
        if(StringUtils.isBlank(bean.getFpxkszt())) {
            bean.setFpxkszt(JcyLxjhConstant.JCYLX_PXZT_WKS);
        }
        if (StringUtils.isBlank(bean.getFjhnd())){
            bean.setFjhnd(DateConversionUtils.DateToYear(new Date()));
        }
        bean.setFpxhgx(60);
        bean.setFpxrs(0);
        bean.setCreateTime(new Date());
        bean.setUpdateTime(new Date());
        bean.setCreateBy(GetCurrentUserUtils.getCurrentUserAccount());
        bean.setUpdateBy(GetCurrentUserUtils.getCurrentUserAccount());
        save(bean);

        String operContent = "新增信息：";
        operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(bean));
        spcyLogService.addLogs(LogConstant.LOGS_JCY_JXJYPX,operContent,bean.getId(), "添加继续教育", SpcyConstant.LOGS_SYS_TYPE_XZ);

        return bean;
    }

    @Override
    public void updateLxjh(HashMap<String, String> buffer) throws InvocationTargetException, IllegalAccessException {
        String id = buffer.get("id");
        if (StringUtils.isEmpty(id)){
            throw new BusinessException("参数为空!");
        }
        SpcyPxJbxx updateBean = getById(id);
        if (updateBean == null){
            throw new BusinessException("没有相匹配数据！");
        }
        String jhzt = updateBean.getFjhzt();

        Map<String, Object> oldMap = ObjectToMapUtils.objectToMap(updateBean);

        ConvertUtils.register(new DateConvert(), java.util.Date.class);
        // 自动完成页面到bean的数据对接
        BeanUtils.populate(updateBean, buffer);

        if (StringUtils.isNotBlank(updateBean.getFjhcjsj())){
            updateBean.setFjhnd(updateBean.getFjhcjsj().substring(0, 4));
        }

        if (StringUtils.isNotBlank(jhzt) && jhzt.equals(JcyLxjhConstant.LX_JHZT_JHQC)){
            if (StringUtils.isNotBlank(updateBean.getFjhcjsj())) {
                String nowDate = DateConversionUtils.DateToStringYYYYMMDD(new Date());
                if (updateBean.getFjhcjsj().compareTo(nowDate) < 0) {
                    updateBean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_QY);
                } else if (updateBean.getFjhcjsj().compareTo(nowDate) == 0) {
                    updateBean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_QY);
                } else {
                    updateBean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
                }
            } else {
                updateBean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
            }

            if (StringUtils.isNotBlank(updateBean.getFjhjzsj())) {
                String nowDate = DateConversionUtils.DateToStringYYYYMMDD(new Date());
                if (updateBean.getFjhjzsj().compareTo(nowDate) < 0) {
                    updateBean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_WKS);
                } else if (updateBean.getFjhjzsj().compareTo(nowDate) > 0) {
                    updateBean.setFpxbmzt(JcyLxjhConstant.JCYLX_PXZT_QY);
                }
            }
        }

        updateBean.setUpdateTime(new Date());
        updateBean.setUpdateBy(GetCurrentUserUtils.getCurrentUserAccount());
        updateById(updateBean);

        String operContent = "基本信息修改：";
        operContent += LogUtils.BeanModifyMsg(updateBean,oldMap);

        spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,operContent,id,"修改遴选计划", SpcyConstant.LOGS_SYS_TYPE_XG);

    }

    @Override
    public void updateJxjy(HashMap<String, String> buffer) throws InvocationTargetException, IllegalAccessException {
        String id = buffer.get("id");
        if (StringUtils.isEmpty(id)){
            throw new BusinessException("参数为空!");
        }
        SpcyPxJbxx updateBean = getById(id);
        if (updateBean == null){
            throw new BusinessException("没有相匹配数据！");
        }
        Map<String, Object> oldMap = ObjectToMapUtils.objectToMap(updateBean);

        ConvertUtils.register(new DateConvert(), java.util.Date.class);
        // 自动完成页面到bean的数据对接
        BeanUtils.populate(updateBean, buffer);

        updateBean.setUpdateTime(new Date());
        updateBean.setUpdateBy(GetCurrentUserUtils.getCurrentUserAccount());
        updateById(updateBean);

        String operContent = "基本信息修改：";
        operContent += LogUtils.BeanModifyMsg(updateBean,oldMap);

        spcyLogService.addLogs(LogConstant.LOGS_JCY_JXJYPX,operContent,id,"修改继续教育", SpcyConstant.LOGS_SYS_TYPE_XG);

    }

    @Override
    public List<String> deleteLxjh(String ids) {
        if (StringUtils.isEmpty(ids)){
            throw new BusinessException("参数为空!");
        }

        List<String> tyDelIdList = new ArrayList<>(); // 允许删除的数据id

        List<String> idsList = StringPatternUtils.getListByIds(ids);
        List<SpcyPxJbxx> list = listByIds(idsList);
        if (CollectionUtil.isNotEmpty(list)){
            for (SpcyPxJbxx bean : list){

                if (StringUtils.isNotBlank(bean.getFjhzt()) && bean.getFjhzt().equals(JcyLxjhConstant.LX_JHZT_JHWC)){
                    throw new BusinessException("存在已经计划完成的数据！无法删除相关数据！");
                }

                tyDelIdList.add(bean.getId());

                removeById(bean.getId());
                spcyPxCjryService.remove(new LambdaQueryWrapper<SpcyPxCjry>().eq(SpcyPxCjry::getFpxjbxxid, bean.getId()));

                spcyJcyLxqdcsService.deleteLxpxqdcsByLxjdId(bean.getId());

                String operContent = "删除信息：";
                operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(bean));
                spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,operContent,bean.getId(), "删除遴选计划", SpcyConstant.LOGS_SYS_TYPE_SC);
            }
        }

        return tyDelIdList;
    }

    @Override
    public void deleteJxjy(String ids) {
        if (StringUtils.isEmpty(ids)){
            throw new BusinessException("参数为空!");
        }
        List<String> idsList = StringPatternUtils.getListByIds(ids);
        List<SpcyPxJbxx> list = listByIds(idsList);
        if (CollectionUtil.isNotEmpty(list)){
            for (SpcyPxJbxx bean : list){

                removeById(bean.getId());

                spcyPxCjryService.remove(new LambdaQueryWrapper<SpcyPxCjry>().eq(SpcyPxCjry::getFpxjbxxid, bean.getId()));

                spcyJcyLxqdcsService.deleteLxpxqdcsByLxjdId(bean.getId());

                String operContent = "删除信息：";
                operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(bean));
                spcyLogService.addLogs(LogConstant.LOGS_JCY_JXJYPX,operContent,bean.getId(), "删除继续教育", SpcyConstant.LOGS_SYS_TYPE_SC);
            }
        }
    }

    @Override
    public void deleteLxjh(List<String> idsList) {
        if (CollectionUtil.isEmpty(idsList)){
            throw new BusinessException("参数为空！");
        }
        List<SpcyPxJbxx> list = listByIds(idsList);
        if (CollectionUtil.isNotEmpty(list)){
            for (SpcyPxJbxx bean : list){
                removeById(bean.getId());

                String operContent = "删除信息：";
                operContent += LogUtils.MapToStringMethod(ObjectToMapUtils.objectToMap(bean));
                spcyLogService.addLogs(LogConstant.LOGS_JCY_LXJHGL,operContent,bean.getId(), "删除遴选计划", SpcyConstant.LOGS_SYS_TYPE_SC);
            }
        }
    }

    @Async(value = "asyncNormalTask")
    @Override
    public void syncCjryKsxx(String pxjbxxid, String userid, String df) {
        if (StringUtils.isBlank(pxjbxxid)){
            return;
        }
        if (StringUtils.isBlank(userid)){
            return;
        }
        if (StringUtils.isBlank(df)){
            df="0";
        }

        SpcyPxCjry cjry = spcyPxCjryService.selectLxCjryByLxjhId(pxjbxxid, userid);
        if (cjry == null){
            return;
        }

        // 获取合格线
        int hgx = 60;
        SpcyPxJbxx jbxx = spcyPxJbxxMapper.selectById(pxjbxxid);
        if (jbxx != null){
            hgx = Optional.ofNullable(jbxx.getFpxhgx()).orElseGet(()->60);
        }

        BigDecimal dfBD = new BigDecimal(df).setScale(0, RoundingMode.HALF_UP);
        if (Integer.valueOf(dfBD.toString()) < hgx){
            cjry.setFkhjg(JcyLxjhConstant.JCYLX_CJRY_KHJG_BHG);
        }else if (Integer.valueOf(dfBD.toString()) >= hgx){
            cjry.setFkhjg(JcyLxjhConstant.JCYLX_CJRY_KHJG_HG);
        }
        cjry.setFksfs(dfBD.toString());
        spcyPxCjryService.updateById(cjry);

    }

    @Override
    public Map verifyCjryKssfgf(String pxjbxxid, String userid, String df, String orghgx) {
        String khjg = JcyLxjhConstant.JCYLX_CJRY_KHJG_HG;

        if (StringUtils.isBlank(df)){
            df = "0";
        }

        int kscs = 0;
        SpcyPxCjry cjry = null;
        if (StringUtils.isNotBlank(pxjbxxid) && StringUtils.isNotBlank(userid)){
            cjry = spcyPxCjryService.selectLxCjryByLxjhId(pxjbxxid, userid);
            if (cjry != null){
                kscs = Optional.ofNullable(cjry.getFkscs()).orElseGet(()->JcyLxjhConstant.JCYLX_CJRY_KSCS);
            }
        }

        // 获取合格线
        int hgx = 60;
        if (StringUtils.isNotBlank(pxjbxxid)) {
            SpcyPxJbxx jbxx = spcyPxJbxxMapper.selectById(pxjbxxid);
            if (jbxx != null) {
                hgx = Optional.ofNullable(jbxx.getFpxhgx()).orElseGet(() -> 60);
            }
        }else {
            try {
                hgx = Integer.valueOf(Optional.ofNullable(orghgx).orElseGet(() -> "60"));
            }catch (Exception e){

            }
        }

        BigDecimal dfBD = new BigDecimal(df).setScale(0, RoundingMode.HALF_UP);
        if (Integer.valueOf(dfBD.toString()) < hgx){
            khjg = JcyLxjhConstant.JCYLX_CJRY_KHJG_BHG;
        }else if (Integer.valueOf(dfBD.toString()) >= hgx){
            khjg = JcyLxjhConstant.JCYLX_CJRY_KHJG_HG;
        }

        // 更新考试次数
        if (cjry != null){
            if (kscs > 0){
                kscs = kscs - 1;
                cjry.setFkscs(kscs);
                spcyPxCjryService.updateById(cjry);
            }
        }

        Map resultMap = new HashMap();
        resultMap.put("flag", khjg);
        resultMap.put("kscs", kscs);
        resultMap.put("ksdf", dfBD.toString());
        resultMap.put("ksfsx", hgx);
        return resultMap;
    }

    @Override
    public StringBuffer syncGenCjryPxjl(SpcyPxJbxx jbxx, List<SpcyPxCjry> cjryList, StringBuffer errorMsg, String pxjbxxid) {
        if (CollectionUtils.isEmpty(cjryList)) {
            return errorMsg;
        }

        for (SpcyPxCjry cjry : cjryList) {
            // 系统不存在的用户，不能生成个人记录
            if (StringUtils.isBlank(cjry.getFuserid())){
                errorMsg.append("【姓名】为[").append(cjry.getRealname()).append("]").append("不存在系统无法生成个人记录。").append("\n");
                continue;
            }

            // 判断是否已经入库
            List<SysUserPxjl> pxList = sysUserPxjlService.list(new LambdaQueryWrapper<SysUserPxjl>()
                    .eq(SysUserPxjl::getFuserid, cjry.getFuserid())
                    .eq(SysUserPxjl::getFpxjbxxid, pxjbxxid)
                    .isNotNull(SysUserPxjl::getFpxjbxxid));
            if (CollectionUtils.isNotEmpty(pxList)){
                errorMsg.append("【姓名】为[").append(cjry.getRealname()).append("]").append("已经生成个人记录。").append("\n");
                continue;
            }

            // 添加用户培训记录
            SysUserPxjl pxjl = new SysUserPxjl();
            BeanUtil.copyProperties(jbxx, pxjl);
            pxjl.setId(GetUuIdUtils.ReplaceUuId());
            pxjl.setFuserid(cjry.getFuserid());
            pxjl.setFusermc(cjry.getRealname());
            pxjl.setFpxly(SpcyConstant.Px_Pxly_Nb); // 内部培训
            pxjl.setFpxjbxxid(jbxx.getId());
            pxjl.setFkhjg(cjry.getFbz()); // 考核等级

            if (StringUtils.isNotBlank(pxjl.getFkhjg()) && pxjl.getFkhjg().equals("不合格")){
                errorMsg.append("【姓名】为[").append(cjry.getRealname()).append("]").append("的【考核成绩】为[不合格]无法生成个人记录。").append("\n");
                continue;
            }
            if (StringUtils.isBlank(cjry.getFbz())){
                errorMsg.append("【姓名】为[").append(cjry.getRealname()).append("]").append("，没有【考核成绩】无法生成个人记录。").append("\n");
                continue;
            }

            if (StringUtils.isBlank(pxjl.getFkhjg())){
                // 计算答卷得分
                String khjg = "不合格";
                List<SpcyPxDjjbxx> userDjList = spcyPxDjjbxxService.list(new LambdaQueryWrapper<SpcyPxDjjbxx>()
                        .eq(SpcyPxDjjbxx::getFpxjbxxid, pxjbxxid)
                        .eq(SpcyPxDjjbxx::getFuserid, cjry.getFuserid()));
                if (CollectionUtils.isNotEmpty(userDjList)){
                    if (StringUtils.isNotBlank(userDjList.get(0).getFdf())) {
                        int fdf = Integer.valueOf(userDjList.get(0).getFdf());
                        if (fdf >= 60) {
                            khjg = "合格";
                        }
                    }
                }

                pxjl.setFkhjg(khjg);
            }

            sysUserPxjlService.save(pxjl);

            String logUserPxJl = "自动生成个人培训记录：";
            Map<String, Object> pxjlMap = ObjectToMapUtils.objectToMap(pxjl);
            logUserPxJl += LogUtils.MapToStringMethod(pxjlMap);
            spcyLogService.addLogs(LogConstant.LOGS_PX_JBXX, logUserPxJl, pxjbxxid, "同步生成个人培训记录", SpcyConstant.LOGS_SYS_TYPE_XZ);
        }

        return errorMsg;
    }

    @Async(value = "asyncNormalTask")
    @Override
    public void syncGenLxUserPxjl(SpcyPxJbxx lxjh, String flxjhid) {
        JcyLxUserVo lxUserVo = new JcyLxUserVo();
        lxUserVo.setFlxjhid(flxjhid);
        lxUserVo.setFsjshzt(JcyLxjhConstant.JCYLX_CJRY_SJSHZT_SHTG);
        lxUserVo.setFkhjg(JcyLxjhConstant.JCYLX_CJRY_KHJG_HG);
        List<JcyLxUserVo> lxUserList = spcyPxJbxxMapper.selectLxjhUserList(lxUserVo, new OrderItemVo());
        if (CollectionUtil.isEmpty(lxUserList)){
            return;
        }

        for (JcyLxUserVo lxUser : lxUserList) {
            // 添加用户培训记录
            SysUserPxjl pxjl = new SysUserPxjl();
            BeanUtil.copyProperties(lxjh, pxjl);
            pxjl.setId(GetUuIdUtils.ReplaceUuId());
            pxjl.setFuserid(lxUser.getFuserid());
            pxjl.setFusermc(lxUser.getRealname());
            pxjl.setFjlnd(lxjh.getFjhnd());
            pxjl.setFpxly(SpcyConstant.Px_Pxly_Nb); // 内部培训
            pxjl.setFpxjbxxid(flxjhid);
            pxjl.setFkhjg(lxUser.getFkhjg()); // 考核结果

            sysUserPxjlService.save(pxjl);

            String logUserPxJl = "遴选人员-自动生成个人培训记录：";
            Map<String, Object> pxjlMap = ObjectToMapUtils.objectToMap(pxjl);
            logUserPxJl += LogUtils.MapToStringMethod(pxjlMap);
            spcyLogService.addLogs(LogConstant.LOGS_PX_JBXX, logUserPxJl, flxjhid, "遴选人员-同步生成个人培训记录", SpcyConstant.LOGS_SYS_TYPE_XZ);

        }

    }
}
